package com.xdjd.mobile.business.api.trade;

import com.gitee.easyopen.annotation.Api;
import com.gitee.easyopen.annotation.ApiService;
import com.gitee.easyopen.doc.DataType;
import com.gitee.easyopen.doc.annotation.ApiDoc;
import com.gitee.easyopen.doc.annotation.ApiDocField;
import com.gitee.easyopen.doc.annotation.ApiDocMethod;
import com.xdjd.mobile.business.entity.param.BasePageParam;
import com.xdjd.mobile.business.entity.param.trade.TradeParam;
import com.xdjd.mobile.business.entity.result.trade.ExchangeRecordResult;
import com.xdjd.mobile.business.entity.result.trade.TradeRecordResult;
import com.xdjd.mobile.business.entity.vo.LoginUser;
import com.xdjd.mobile.business.service.TradeService;
import com.xdjd.mobile.system.ApiUtil;
import net.oschina.durcframework.easymybatis.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

@ApiService
@ApiDoc("交易兑换记录")
public class TradeApi {

    @Autowired
    private TradeService tradeService;

    @Api(name = "trade.record.get")
    @ApiDocMethod(description = "获取交易记录列表", results = {@ApiDocField(name = "pageIndex", description = "第几页", dataType = DataType.INT, example = "1"),
            @ApiDocField(name = "pageSize", description = "每页几条数据", dataType = DataType.INT, example = "2"),
            @ApiDocField(name = "total", description = "总记录数", dataType = DataType.LONG, example = "100"),
            @ApiDocField(name = "list", description = "数据", dataType = DataType.ARRAY, elementClass = TradeRecordResult.class),})
    public PageInfo<TradeRecordResult> getTradeRecordList(TradeParam param) {
        LoginUser currentUser = ApiUtil.getCurrentUser();
        return tradeService.getTradeRecordList(param, currentUser.getId());
    }

    @Api(name = "exchange.record.get")
    @ApiDocMethod(description = "获取兑换记录列表", results = {@ApiDocField(name = "pageIndex", description = "第几页", dataType = DataType.INT, example = "1"),
            @ApiDocField(name = "pageSize", description = "每页几条数据", dataType = DataType.INT, example = "2"),
            @ApiDocField(name = "total", description = "总记录数", dataType = DataType.LONG, example = "100"),
            @ApiDocField(name = "list", description = "数据", dataType = DataType.ARRAY, elementClass = ExchangeRecordResult.class),})
    public PageInfo<ExchangeRecordResult> getExchangeRecordList(BasePageParam param) {
        LoginUser currentUser = ApiUtil.getCurrentUser();
        return tradeService.getExchangeRecordList(param.getPageIndex(), param.getPageSize(), currentUser.getId());
    }
}
